package DP;

/**
 * @author 曹见朋
 * @create 2024-06-11-23:42
 */
public class Main96 {
    // TODO 96. 不同的二叉搜索树
    public static int numTrees(int n) {
        int[] dp = new int[n + 1];
        dp[0] = 1;
        dp[1] = 1;
        for(int i = 2; i <= n; i++){
            for(int j = 1; j <= i; j++){
                dp[i] += dp[j - 1] * dp[i - j];
            }
        }

        for(int i = 0; i <= n; i++){
            System.out.print(" " + dp[i]);
        }

        return dp[n];

    }

    public static void main(String[] args) {
        int n = 3;
        int result = numTrees(n);
        System.out.println();
        System.out.println(result);
    }
}
